Ext.require('AM.service.Support');
Ext.define('AM.component.Table', {
    extend:'Ext.Component',

    xtype: 'xbxTable',


    autoEl: 'table',

    config: {
        rowNum: 5,
        colNum : 5
    },


    constructor:function (config) {
        var me = this;
        me.callParent(arguments);
        me.initConfig(config);

        me.addListener('render', function(){
            // add tr & td
            var createTR = function () {
                var row = Ext.DomHelper.createDom({
                    tag:'tr'
                });
                return row;
            };
            var createTD = function () {
                return Ext.DomHelper.createDom({
                    tag:'td',
                    style:{
                        border:'solid 2px'
                    },
                    contenteditable: true

                });
            }
            for (var i = 0; i < me.rowNum; i++) {
                var tr = createTR();
                me.el.dom.appendChild(tr);
                for (var j = 0; j < me.colNum; j++) {
                    var td = createTD();
                    tr.appendChild(td);
                }
            }


            // add support fn
            var sp = AM.service.Support;
            sp.drag(me);
            sp.contextmenu(me);
            sp.cacheCmp(me);
            sp.animShow(me);
        })
    },

    width: 200,
    height: 200,

    style:{
        position:'absolute',
        border:'2px dashed #0687FF'
    }



});